/**********************************************/
/************* PRELIMINARY AND LOGS ***********/
/**********************************************/

cd "/Users/alex/Dropbox/Papers Essex/Virus/Universities/New Version/Submission/Revision"

log using "Replication_PlosOne_Revision_Log.smcl",replace

set seed 777777777

/**********************************************/
/**********************************************/
/**********  SINGLE RECORD TWITTER ************/
/**********************************************/
/**********************************************/

use "PlosOne_Twitter_Cox_Replication.dta",clear

/*stset*/
stdescribe
stci, p(50)

/*Fig 1. Survivor function of days to first Covid-19 tweet.*/
sts graph if time_to_first_tweet<=100, ci ///
plotopts(recast(line) lpattern(solid) lwidth(medthick) lcolor(pink)) ///
ciopts(recast(rarea) fcolor(lavender) fintensity(inten20) lcolor(lavender)) ///
xline(13 24 29 45 59 73 83, lwidth(medthick) lcolor(gold)) ///
ytitle("{stSerif:S(t)}") xtitle("{stSerif:Date}") title("") legend(off) ///
xlabel(0 "{stSerif:31/12/19}" 13 "{stSerif:13/01}" 24 "{stSerif:24/01}" ///
29 "{stSerif:29/01}" 45 "{stSerif:14/02}" 59 "{stSerif:28/02}" 73 "{stSerif:13/03}" ///
83 "{stSerif:23/03}", valuelabel angle(forty_five)) ///
ylabel(1 "{stSerif:1}" .75 "{stSerif:.75}" .5 "{stSerif:.5}" ///
.25 "{stSerif:.25}" 0 "{stSerif:0}") ///
text(.75 13 "{stSerif:1st out China}",place(w) size(small)) ///
text(.65 24 "{stSerif:1st in EU}",place(w) size(small)) ///
text(.5 29 "{stSerif:1st UK}",place(w)size(small)) ///
text(.37 45 "{stSerif:1st death EU}",place(w)size(small)) ///
text(.25 59 "{stSerif:1st trans UK}",place(w)size(small)) ///
text(.12 73 "{stSerif:Soc Dist UK}",place(w)size(small)) ///
text(.37 83 "{stSerif:Lockdown}",place(e)size(small))
graph save Graph "Fig1.gph",replace
graph export "Fig1.tif", width(1560) height(1100)


/*Drop oxford and cambridge*/
drop if uni_id==29
drop if uni_id==108

*Resources*/
sum tot_reserves_mil 
sum unrestrc_resrv_mil


/**********************************************/
/*S2 Table: summary statistics*/
/**********************************************/

qui stcox ln_tot_students_res prop_tuit_income ln_tot_reserves_mil   ///
ln_engage_free russ_grp, ///
 cluster(utla_code)
tabstat ln_tot_students_res prop_tuit_income ln_tot_reserves_mil   ///
ln_engage_free russ_grp build_pc  ln_unrestrc_resrv_mil if e(sample)==1, ///
stat(n mean v min max) columns(statistics) format(%9.2f)

/**********************************************/
/*Table 1 in manuscript: Cox Models of Days to First Covid-19 Tweet.*/
/**********************************************/

*Model 1*
stcox ln_tot_students_res prop_tuit_income ln_tot_reserves_mil   ///
ln_engage_free russ_grp, ///
 cluster(utla_code)
eststo t1m1
estat phtest, detail
estat phtest, detail log
estat phtest, detail km
estat phtest, detail rank

*Model 2*
stcox ln_tot_students_res prop_tuit_income ln_tot_reserves_mil   ///
ln_engage_free russ_grp  ///
build_pc, ///
 cluster(utla_code)
eststo t1m2
/*slightly not prop*/
estat phtest, detail
/*slightly not prop*/
estat phtest, detail log
estat phtest, detail km
estat phtest, detail rank

*Model 3*
stcox ln_tot_students_res prop_tuit_income ln_unrestrc_resrv_mil   ///
ln_engage_free russ_grp, ///
 cluster(utla_code)
eststo t1m3
/*more not prop*/
estat phtest, detail
/*more not prop*/
estat phtest, detail log
estat phtest, detail km
estat phtest, detail rank

/*Table Output*/
esttab t1m1 t1m2 t1m3 using Table1_hr.rtf, se parentheses nogaps ///
label mtitle("Model 1" "Model 2" "Model 3") star(* 0.1 ** 0.05 *** 0.01) ///
scalars("N Observations" "N_sub Subjects" "N_fail Failures" ///
"N_clust Clusters" "ll Log L") eform  constant replace

/**********************************************/
/*S1 Table: Verified Twitter accounts.*/
/**********************************************/

tab not_verified_10apr20
drop if not_verified_10apr20==1

stset, clear
stset time_to_first_tweet,failure(tweet=1)

*Model 1*
stcox ln_tot_students_res prop_tuit_income ln_tot_reserves_mil   ///
ln_engage_free russ_grp, ///
 cluster(utla_code)
eststo s1m1

*Model 2*
stcox ln_tot_students_res prop_tuit_income ln_tot_reserves_mil   ///
ln_engage_free russ_grp  ///
build_pc, ///
 cluster(utla_code)
eststo s1m2

*Model 3*
stcox ln_tot_students_res prop_tuit_income ln_unrestrc_resrv_mil   ///
ln_engage_free russ_grp, ///
 cluster(utla_code)
eststo s1m3

/*Table Output*/
esttab s1m1 s1m2 s1m3 using S1_hr.rtf, se parentheses nogaps ///
label mtitle("Model 1" "Model 2" "Model 3") star(* 0.1 ** 0.05 *** 0.01) ///
scalars("N Observations" "N_sub Subjects" "N_fail Failures" ///
"N_clust Clusters" "ll Log L") eform constant replace

/**********************************************/
/**********************************************/
/**************  DYADIC TWITTER ***************/
/**********************************************/
/**********************************************/

use "PlosOne_Twitter_Dyadic_Replication.dta",clear

/*Drop oxford and cambridge*/
drop if uni_id_01==29 | uni_id_02==29
drop if uni_id_01==108 | uni_id_02==108

/*Sample from Model 2 in table 2*/
qui logit emul_net ln_tot_students_res_01 prop_tuit_income_01 ln_tot_reserves_mil_01 ///
ln_engage_free_01 russ_grp_01 ln_dailycases_01 time time2_01 time3_01 ///
ln_tot_students_res_02 prop_tuit_income_02 ln_tot_reserves_mil_02 ///
ln_engage_free_02 russ_grp_02 ln_dailycases_02 ///
l2.prov_has_1_02 l2.nbr_prov_has_1_02  ///
if uni_id_01!=uni_id_02 & day<td(30apr2020), cluster(uni_id_01) or
gen m2sample=e(sample)

/*Tab emulation*/
tab emul_net if m2sample==1

/*Tab B Tweeted*/
tab prov_has_1_02 if m2sample==1

/*Neighbors*/
sum nbr if m2sample==1

/*Covid cases*/
sum dailylabconfirmedcases_01 if m2sample==1,detail

/*Tab emulation opportunity*/
tab emul_opp_net if m2sample==1

/*Tab emulation opportunity and emulation*/
tab emul_net emul_opp_net if m2sample==1

*Tab emulation opportunity and B tweeted*/
tab emul_opp_net prov_has_1_02 if m2sample==1

/**********************************************/
*Table 2 in manuscript: Models of first Covid-19 tweet and emulation of first Covid-19 tweet.*/
/**********************************************/

/*Model 1: Monadic */
logit prov1_01 ln_tot_students_res_01 prop_tuit_income_01 ln_tot_reserves_mil_01 ///
ln_engage_free_01 russ_grp_01 ln_dailycases_01 time time2_01 time3_01 ///
if uni_id_01==uni_id_02 & day<td(30apr2020), ///
cluster(uni_id_01) or
eststo t2m1
/*Tab B Tweeted*/
tab prov1_01 if e(sample)==1

/*Model 2: Dyadic Unconditional*/
logit emul_net ln_tot_students_res_01 prop_tuit_income_01 ln_tot_reserves_mil_01 ///
ln_engage_free_01 russ_grp_01 ln_dailycases_01 time time2_01 time3_01 ///
ln_tot_students_res_02 prop_tuit_income_02 ln_tot_reserves_mil_02 ///
ln_engage_free_02 russ_grp_02 ln_dailycases_02 ///
l2.prov_has_1_02 l2.nbr_prov_has_1_02  ///
if uni_id_01!=uni_id_02 & day<td(30apr2020), cluster(uni_id_01) or
eststo t2m2
lincom l2.prov_has_1_02 +l2.nbr_prov_has

/*Model 3: Dyadic Conditional*/
logit emul_net ln_tot_students_res_01 prop_tuit_income_01 ln_tot_reserves_mil_01 ///
ln_engage_free_01 russ_grp_01 ln_dailycases_01 time time2_01 time3_01 ///
ln_tot_students_res_02 prop_tuit_income_02 ln_tot_reserves_mil_02 ///
ln_engage_free_02 russ_grp_02 ln_dailycases_02 ///
nbr ///
if uni_id_01!=uni_id_02  & emul_opp_net==1 & day<td(30apr2020), cluster(uni_id_01) or
eststo t2m3

/*Table Output*/
esttab t2m1 t2m2 t2m3 using Table2_hr.rtf, se parentheses nogaps ///
label mtitle("Model 1" "Model 2" "Model 3") star(* 0.1 ** 0.05 *** 0.01) ///
scalars("N Observations" "N_clust Clusters" "r2_p Pseudo-R2" "ll Log L") eform constant replace

/**********************************************/
/*S5 Table. Additional lags for Model 2 in Table 2 (dyadic unconditional).*/
/**********************************************/

/*Model 2: Dyadic Unconditional, 3 LAGS*/
logit emul_net ln_tot_students_res_01 prop_tuit_income_01 ln_tot_reserves_mil_01 ///
ln_engage_free_01 russ_grp_01 ln_dailycases_01 time time2_01 time3_01 ///
ln_tot_students_res_02 prop_tuit_income_02 ln_tot_reserves_mil_02 ///
ln_engage_free_02 russ_grp_02 ln_dailycases_02 ///
l3.prov_has_1_02 l3.nbr_prov_has_1_02  ///
if uni_id_01!=uni_id_02 & day<td(30apr2020), cluster(uni_id_01) or
eststo s5m1

/*Model 2: Dyadic Unconditional, 4 LAGS*/
logit emul_net ln_tot_students_res_01 prop_tuit_income_01 ln_tot_reserves_mil_01 ///
ln_engage_free_01 russ_grp_01 ln_dailycases_01 time time2_01 time3_01 ///
ln_tot_students_res_02 prop_tuit_income_02 ln_tot_reserves_mil_02 ///
ln_engage_free_02 russ_grp_02 ln_dailycases_02 ///
l4.prov_has_1_02 l4.nbr_prov_has_1_02  ///
if uni_id_01!=uni_id_02 & day<td(30apr2020), cluster(uni_id_01) or
eststo s5m2

/*Table Output*/
esttab s5m1 s5m2 using S5_hr.rtf, se parentheses nogaps ///
label mtitle("Model 1" "Model 2") star(* 0.1 ** 0.05 *** 0.01) ///
scalars("N Observations" "N_clust Clusters" "r2_p Pseudo-R2" "ll Log L") eform constant replace


/**********************************************/
/*S6 Table. Alternative definitions of a neighbourhood for dyadic models of Table 2..*/
/**********************************************/

******************** Dyadic Unconditional**************************

/*Neighborhood of 100km*/
inspect cont

gen nbr2=0  
replace nbr2=1 if cont<=100000
gen nbr2_prov_has_1_02=nbr2* prov_has_1_02
order cont nbr nbr2 ,after(emul_opp_net)
tab nbr
tab nbr2

logit emul_net ln_tot_students_res_01 prop_tuit_income_01 ln_tot_reserves_mil_01 ///
ln_engage_free_01 russ_grp_01 ln_dailycases_01 time time2_01 time3_01 ///
ln_tot_students_res_02 prop_tuit_income_02 ln_tot_reserves_mil_02 ///
ln_engage_free_02 russ_grp_02 ln_dailycases_02 ///
l2.prov_has_1_02 l2.nbr2_prov_has_1_02  ///
if uni_id_01!=uni_id_02 & day<td(30apr2020), cluster(uni_id_01) or
eststo s6m1

/*Neighborhood of 25km*/
gen nbr3=0  
replace nbr3=1 if cont<=25000
gen nbr3_prov_has_1_02=nbr3* prov_has_1_02
order cont nbr nbr2 nbr3,after(emul_opp_net)
tab nbr
tab nbr2
tab nbr3

logit emul_net ln_tot_students_res_01 prop_tuit_income_01 ln_tot_reserves_mil_01 ///
ln_engage_free_01 russ_grp_01 ln_dailycases_01 time time2_01 time3_01 ///
ln_tot_students_res_02 prop_tuit_income_02 ln_tot_reserves_mil_02 ///
ln_engage_free_02 russ_grp_02 ln_dailycases_02 ///
l2.prov_has_1_02 l2.nbr3_prov_has_1_02  ///
if uni_id_01!=uni_id_02 & day<td(30apr2020), cluster(uni_id_01) or
eststo s6m2

******************** Dyadic Conditional **************************

/*Neighborhood of 100km*/
logit emul_net ln_tot_students_res_01 prop_tuit_income_01 ln_tot_reserves_mil_01 ///
ln_engage_free_01 russ_grp_01 ln_dailycases_01 time time2_01 time3_01 ///
ln_tot_students_res_02 prop_tuit_income_02 ln_tot_reserves_mil_02 ///
ln_engage_free_02 russ_grp_02 ln_dailycases_02 ///
nbr2 ///
if uni_id_01!=uni_id_02  & emul_opp_net==1 & day<td(30apr2020), cluster(uni_id_01) or
eststo s6m3

/*Neighborhood of 25km*/
logit emul_net ln_tot_students_res_01 prop_tuit_income_01 ln_tot_reserves_mil_01 ///
ln_engage_free_01 russ_grp_01 ln_dailycases_01 time time2_01 time3_01 ///
ln_tot_students_res_02 prop_tuit_income_02 ln_tot_reserves_mil_02 ///
ln_engage_free_02 russ_grp_02 ln_dailycases_02 ///
nbr3 ///
if uni_id_01!=uni_id_02  & emul_opp_net==1 & day<td(30apr2020), cluster(uni_id_01) or
eststo s6m4

esttab s6m1 s6m2 s6m3 s6m4 using S6_hr.rtf, se parentheses nogaps ///
label mtitle("Model 1" "Model 2" "Model 3" "Model 4") star(* 0.1 ** 0.05 *** 0.01) ///
scalars("N Observations" "N_clust Clusters" "r2_p Pseudo-R2" "ll Log L") constant eform replace

/**********************************************/
/**********************************************/
/**********  SINGLE RECORD WEBPAGES ***********/
/**********************************************/
/**********************************************/

use "PlosOne_Webpages_Cox_Replication.dta",clear

/*stset*/
stdescribe
stci, p(50)

/*Fig 2. Survivor Function of Days to First Covid-19 Webpage.*/
sts graph, ci ///
plotopts(recast(line) lpattern(solid) lwidth(medthick) lcolor(pink)) ///
ciopts(recast(rarea) fcolor(lavender) fintensity(inten20) lcolor(lavender)) ///
xline(13 24 29 45 59 73 83, lwidth(medthick) lcolor(gold)) ///
ytitle("{stSerif:S(t)}") xtitle("{stSerif:Date}") title("") legend(off) ///
xlabel(0 "{stSerif:31/12/19}" 13 "{stSerif:13/01}" 24 "{stSerif:24/01}" ///
29 "{stSerif:29/01}" 45 "{stSerif:14/02}" 59 "{stSerif:28/02}" 73 "{stSerif:13/03}" ///
83 "{stSerif:23/03}", valuelabel angle(forty_five)) ///
ylabel(1 "{stSerif:1}" .75 "{stSerif:.75}" .5 "{stSerif:.5}" ///
.25 "{stSerif:.25}" 0 "{stSerif:0}") ///
text(.75 13 "{stSerif:1st out China}",place(w) size(small)) ///
text(.65 24 "{stSerif:1st in EU}",place(w) size(small)) ///
text(.5 29 "{stSerif:1st UK}",place(w)size(small)) ///
text(.37 45 "{stSerif:1st death EU}",place(w)size(small)) ///
text(.25 59 "{stSerif:1st trans UK}",place(w)size(small)) ///
text(.12 73 "{stSerif:Soc Dist UK}",place(w)size(small)) ///
text(.37 83 "{stSerif:Lockdown}",place(e)size(small))
graph save Graph "Fig2.gph",replace
graph export "Fig2.tif", width(1560) height(1100)

/*Drop oxford and cambridge*/
drop if uni_id==29
drop if uni_id==108

/**********************************************/
/*Table 3 in manuscript: Cox Models of Days to First Covid-19 Webpage.*/
/**********************************************/

*Model 1*
stcox ln_tot_students_res prop_tuit_income ln_tot_reserves_mil   ///
ln_engage_free russ_grp, ///
 cluster(utla_code)
eststo t3m1
estat phtest, detail
/*Slightly non-prop*/
estat phtest, detail log
estat phtest, detail km
estat phtest, detail rank

*Model 2*
stcox ln_tot_students_res prop_tuit_income ln_tot_reserves_mil   ///
ln_engage_free russ_grp  ///
build_pc, ///
 cluster(utla_code)
eststo t3m2
estat phtest, detail
/*Slightly non-prop*/
estat phtest, detail log
estat phtest, detail km
estat phtest, detail rank

*Model 3*
stcox ln_tot_students_res prop_tuit_income ln_unrestrc_resrv_mil   ///
ln_engage_free russ_grp, ///
 cluster(utla_code)
eststo t3m3
/*More non-prop*/
estat phtest, detail
/*More non-prop*/
estat phtest, detail log
estat phtest, detail km
estat phtest, detail rank

/*Table Output*/
esttab t3m1 t3m2 t3m3 using Table3_hr.rtf, se parentheses nogaps ///
label mtitle("Model 1" "Model 2" "Model 3") star(* 0.1 ** 0.05 *** 0.01) ///
scalars("N Observations" "N_sub Subjects" "N_fail Failures" ///
"N_clust Clusters" "ll Log L") eform constant replace


/**************************************/
/**************************************/
/*********** DYADIC WEBPAGES **********/
/**************************************/
/**************************************/

use "PlosOne_Webpages_Dyadic_Replication.dta",clear

/*Drop oxford and cambridge*/
drop if uni_id_01==29 | uni_id_02==29
drop if uni_id_01==108 | uni_id_02==108

/*Sample from Model 2 in Table 4*/
qui logit emul_net ln_tot_students_res_01 prop_tuit_income_01 ln_tot_reserves_mil_01 ///
ln_engage_free_01 russ_grp_01 ln_dailycases_01 time time2_01 time3_01 ///
ln_tot_students_res_02 prop_tuit_income_02 ln_tot_reserves_mil_02 ///
ln_engage_free_02 russ_grp_02 ln_dailycases_02 ///
l2.prov_has_1_02 l2.nbr_prov_has_1_02  ///
if uni_id_01!=uni_id_02 & day<td(30apr2020), cluster(uni_id_01) or
gen m2sample=e(sample)

/*Tab B Posted*/
tab prov_has_1_02 if m2sample==1

/*Tab emulation*/
tab emul_net if m2sample==1

/*Tab emulation opportunity*/
tab emul_opp_net if m2sample==1

/*Neighbors*/
sum nbr if m2sample==1

/*Covid cases*/
sum dailylabconfirmedcases_01 if m2sample==1,detail

/*Tab emulation opportunity and emulation*/
tab emul_net emul_opp_net if m2sample==1

*Tab emulation opportunity and B tweeted*/
tab emul_opp_net prov_has_1_02 if m2sample==1

/**********************************************/
/*Table 4 in manuscript: Models of first Covid-19 webpage and emulation of first Covid-19 webpage.*/
/**********************************************/

/*Model 1: Monadic */
logit prov1_01 ln_tot_students_res_01 prop_tuit_income_01 ln_tot_reserves_mil_01 ///
ln_engage_free_01 russ_grp_01 ln_dailycases_01 time time2_01 time3_01 ///
if uni_id_01==uni_id_02 & day<td(30apr2020), ///
cluster(uni_id_01) or
eststo t4m1

/*Model 2: Dyadic Unconditional*/
logit emul_net ln_tot_students_res_01 prop_tuit_income_01 ln_tot_reserves_mil_01 ///
ln_engage_free_01 russ_grp_01 ln_dailycases_01 time time2_01 time3_01 ///
ln_tot_students_res_02 prop_tuit_income_02 ln_tot_reserves_mil_02 ///
ln_engage_free_02 russ_grp_02 ln_dailycases_02 ///
l2.prov_has_1_02 l2.nbr_prov_has_1_02  ///
if uni_id_01!=uni_id_02 & day<td(30apr2020), cluster(uni_id_01) or
eststo t4m2
lincom l2.prov_has_1_02 +l2.nbr_prov_has

/*Model 3: Dyadic Conditional*/
logit emul_net ln_tot_students_res_01 prop_tuit_income_01 ln_tot_reserves_mil_01 ///
ln_engage_free_01 russ_grp_01 ln_dailycases_01 time time2_01 time3_01 ///
ln_tot_students_res_02 prop_tuit_income_02 ln_tot_reserves_mil_02 ///
ln_engage_free_02 russ_grp_02 ln_dailycases_02 ///
nbr ///
if uni_id_01!=uni_id_02  & emul_opp_net==1 & day<td(30apr2020), cluster(uni_id_01) or
eststo t4m3

/*Table Output*/
esttab t4m1 t4m2 t4m3 using Table4_hr.rtf, se parentheses nogaps ///
label mtitle("Model 1" "Model 2" "Model 3") star(* 0.1 ** 0.05 *** 0.01) ///
scalars("N Observations" "N_clust Clusters" "r2_p Pseudo-R2" "ll Log L") eform constant replace

/**********************************************/
/*S7 Table. Additional lags for Model 2 in Table 4 (dyadic unconditional).*/
/**********************************************/

/*Model 2: Dyadic Unconditional, 3 LAGS*/
logit emul_net ln_tot_students_res_01 prop_tuit_income_01 ln_tot_reserves_mil_01 ///
ln_engage_free_01 russ_grp_01 ln_dailycases_01 time time2_01 time3_01 ///
ln_tot_students_res_02 prop_tuit_income_02 ln_tot_reserves_mil_02 ///
ln_engage_free_02 russ_grp_02 ln_dailycases_02 ///
l3.prov_has_1_02 l3.nbr_prov_has_1_02  ///
if uni_id_01!=uni_id_02 & day<td(30apr2020), cluster(uni_id_01) or
eststo s7m1

/*Model 2: Dyadic Unconditional, 4 LAGS*/
logit emul_net ln_tot_students_res_01 prop_tuit_income_01 ln_tot_reserves_mil_01 ///
ln_engage_free_01 russ_grp_01 ln_dailycases_01 time time2_01 time3_01 ///
ln_tot_students_res_02 prop_tuit_income_02 ln_tot_reserves_mil_02 ///
ln_engage_free_02 russ_grp_02 ln_dailycases_02 ///
l4.prov_has_1_02 l4.nbr_prov_has_1_02  ///
if uni_id_01!=uni_id_02 & day<td(30apr2020), cluster(uni_id_01) or
eststo s7m2

/*Table Output*/
esttab s7m1 s7m2 using S7_hr.rtf, se parentheses nogaps ///
label mtitle("Model 1" "Model 2") star(* 0.1 ** 0.05 *** 0.01) ///
scalars("N Observations" "N_clust Clusters" "r2_p Pseudo-R2" "ll Log L") eform constant replace

/**********************************************/
/*S8 Table. Alternative definitions of a neighbourhood for dyadic models of Table 4.*/
/**********************************************/

******************** Dyadic Unconditional**************************

/*Neighborhood of 100km*/
inspect cont

gen nbr2=0  
replace nbr2=1 if cont<=100000
gen nbr2_prov_has_1_02=nbr2* prov_has_1_02
order cont nbr nbr2 ,after(emul_opp_net)
tab nbr
tab nbr2

logit emul_net ln_tot_students_res_01 prop_tuit_income_01 ln_tot_reserves_mil_01 ///
ln_engage_free_01 russ_grp_01 ln_dailycases_01 time time2_01 time3_01 ///
ln_tot_students_res_02 prop_tuit_income_02 ln_tot_reserves_mil_02 ///
ln_engage_free_02 russ_grp_02 ln_dailycases_02 ///
l2.prov_has_1_02 l2.nbr2_prov_has_1_02  ///
if uni_id_01!=uni_id_02 & day<td(30apr2020), cluster(uni_id_01) or
eststo s8m1

/*Neighborhood of 25km*/
gen nbr3=0  
replace nbr3=1 if cont<=25000
gen nbr3_prov_has_1_02=nbr3* prov_has_1_02
order cont nbr nbr2 nbr3,after(emul_opp_net)
tab nbr
tab nbr2
tab nbr3

logit emul_net ln_tot_students_res_01 prop_tuit_income_01 ln_tot_reserves_mil_01 ///
ln_engage_free_01 russ_grp_01 ln_dailycases_01 time time2_01 time3_01 ///
ln_tot_students_res_02 prop_tuit_income_02 ln_tot_reserves_mil_02 ///
ln_engage_free_02 russ_grp_02 ln_dailycases_02 ///
l2.prov_has_1_02 l2.nbr3_prov_has_1_02  ///
if uni_id_01!=uni_id_02 & day<td(30apr2020), cluster(uni_id_01) or
eststo s8m2

******************** Dyadic Conditional**************************

/*Neighborhood of 100km*/
logit emul_net ln_tot_students_res_01 prop_tuit_income_01 ln_tot_reserves_mil_01 ///
ln_engage_free_01 russ_grp_01 ln_dailycases_01 time time2_01 time3_01 ///
ln_tot_students_res_02 prop_tuit_income_02 ln_tot_reserves_mil_02 ///
ln_engage_free_02 russ_grp_02 ln_dailycases_02 ///
nbr2 ///
if uni_id_01!=uni_id_02  & emul_opp_net==1 & day<td(30apr2020), cluster(uni_id_01) or
eststo s8m3

/*Neighborhood of 25km*/
logit emul_net ln_tot_students_res_01 prop_tuit_income_01 ln_tot_reserves_mil_01 ///
ln_engage_free_01 russ_grp_01 ln_dailycases_01 time time2_01 time3_01 ///
ln_tot_students_res_02 prop_tuit_income_02 ln_tot_reserves_mil_02 ///
ln_engage_free_02 russ_grp_02 ln_dailycases_02 ///
nbr3 ///
if uni_id_01!=uni_id_02  & emul_opp_net==1 & day<td(30apr2020), cluster(uni_id_01) or
eststo s8m4

esttab s8m1 s8m2 s8m3 s8m4 using S8_hr.rtf, se parentheses nogaps ///
label mtitle("Model 1" "Model 2" "Model 3" "Model 4") star(* 0.1 ** 0.05 *** 0.01) ///
scalars("N Observations" "N_clust Clusters" "r2_p Pseudo-R2" "ll Log L") eform constant replace

/**********************************************/
/*S2 Table. Additional controls for university leadership for Model 1 in Table 1 and Model 1 in Table 3.*/
/**********************************************/

******************** Twitter **************************

use "PlosOne_Twitter_Cox_Replication.dta",clear

/*stset*/
stdescribe
stci, p(50)

/*Drop oxford and cambridge*/
drop if uni_id==29
drop if uni_id==108

/*Check correct data*/
*Model 1 from Table 1*
stcox ln_tot_students_res prop_tuit_income ln_tot_reserves_mil   ///
ln_engage_free russ_grp, ///
 cluster(utla_code)

gen prop_fem=et_fem/et_size

*Model 1 from Table 1 with VC gender*
stcox ln_tot_students_res prop_tuit_income ln_tot_reserves_mil   ///
ln_engage_free russ_grp vc_gend, ///
 cluster(utla_code)
eststo s2m1
sum vc_gend prop_fem if e(sample)==1

*Model 1 from Table 1 with VC gender and team*
stcox ln_tot_students_res prop_tuit_income ln_tot_reserves_mil   ///
ln_engage_free russ_grp vc_gend prop_fem, ///
 cluster(utla_code)
 eststo s2m2

 
******************** Webpages **************************

use "PlosOne_Webpages_Cox_Replication.dta",clear

/*stset*/
stdescribe
stci, p(50)

/*Drop oxford and cambridge*/
drop if uni_id==29
drop if uni_id==108

/*Check correct data*/
*Model 1 from Table 3*
stcox ln_tot_students_res prop_tuit_income ln_tot_reserves_mil   ///
ln_engage_free russ_grp, ///
 cluster(utla_code)

gen prop_fem=et_fem/et_size

*Model 1 from Table 3 with VC gender*
stcox ln_tot_students_res prop_tuit_income ln_tot_reserves_mil   ///
ln_engage_free russ_grp vc_gend, ///
 cluster(utla_code)
eststo s2m3
sum vc_gend prop_fem if e(sample)==1

*Model 1 from Table 3 with VC gender and team*

stcox ln_tot_students_res prop_tuit_income ln_tot_reserves_mil   ///
ln_engage_free russ_grp vc_gend prop_fem, ///
 cluster(utla_code)
eststo s2m4

/*Table Output*/
esttab s2m1 s2m2 s2m3 s2m4 using S2_hr.rtf, se parentheses nogaps ///
label mtitle("Model 1" "Model 2") star(* 0.1 ** 0.05 *** 0.01) ///
scalars("N Observations" "N_sub Subjects" "N_fail Failures" ///
"N_clust Clusters" "ll Log L") eform constant replace

log close
